#include <string.h>
#include <sdcc-lib.h>

#if !_SDCC_PORT_PROVIDES_MEMCPY

#undef memcpy /* Avoid conflict with builtin memcpy() in Z80 and some related ports */

void * memcpy( void * dst, const void * src, size_t acount ) {
  void * ret = dst;
  char * d = dst;
  const char * s = src;
  /*
     copy from lower addresses to higher addresses
  */
  while( acount-- ) {
    *d++ = *s++;
  }
  return( ret );
}
#endif
